# from pymilvus import connections, db
# # Connect to Milvus
# connections.connect("default", host="localhost", port="19530", user="root", password="Milvus")
# # List all databases
# databases = db.list_database()
# print(databases)
from pymilvus import MilvusClient
client = MilvusClient(
    uri="http://localhost:19530",
    user="root",
    password="Milvus",
    database="gary_db"
)

res = client.list_collections()
print(res)

client.load_collection(
    collection_name="topic_collection",
    sync=False,
)

query_vectors = [0.1, 0.2, 0.3, 0.4, 0.5]
res = client.search(
    collection_name="topic_collection",
    anns_field="vector",
    data=[query_vectors],
    limit=2,
    output_fields=["vector", "category"],
)
for val in res:
    for v in val:
        print(v)
